<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<title>影像采集详细信息</title>
<link rel="stylesheet" type="text/css" href="${ctx}/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${ctx}/easyui/easyui_my.css">
<link rel="stylesheet" type="text/css" href="${ctx}/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="${ctx}/css/css.css" />
<style type="text/css">
    .panel-title{ color: #444444;}
</style>
<script type="text/javascript" src="${ctx}/js/jquery-1.7.min.js"></script>
<script type="text/javascript" src="${ctx}/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${ctx }/easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${ctx}/js/common.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery.form.js"></script>
<script type="text/javascript" src="${ctx}/js/jqzoom.pack.1.0.1.js"></script>
<script type="text/javascript" src="${ctx}/js/MapUtil.js"></script>
<style type="text/css">
#wfdd_chzn{
 display: none;
}
img {
    vertical-align: top;
}
.progress { position:relative; width:400px; border: 2px solid #ddd; padding: 1px; border-radius: 5px; }
.bar { position:absolute;background-color: #006400; width:10%; height:30px; border-radius: 3px;}
.percent { position:absolute; display:inline-block; top:3px; left:45%;font-weight:bold }
.mask {       
            position: absolute; top: 0px; filter: alpha(opacity=80); background-color: #ddd;
            z-index: 1002; left: 0px;     
            opacity:0.5; -moz-opacity:0.5;     
        }
div#parameters {float:right;}
div#parameters td {padding:6px;}
</style>

</head>

<script>
//显示遮罩层    
function showMask(){     
    $("#mask").css("height",$(document).height());     
    $("#mask").css("width",$(document).width());     
    $("#mask").show();     
}  
//隐藏遮罩层  
function hideMask(){     
      
    $("#mask").hide();     
} 
     $(function(){
        var bar = $('.bar');
        var percent = $('.percent');
        var status = $('#status');
        $('#uploadPicForm').ajaxForm({
            beforeSerialize:function(){
                //alert("表单数据序列化前执行的操作！");
                //$("#txt2").val("java");//如：改变元素的值
            },
            beforeSubmit:function(){
            	try{
              		var listImgObj=document.getElementById("yxxxinfo").getElementsByTagName("img");
              		}catch(e){
              			alert("无档案信息,请上传档案文件后再保存！");
              			return;
              		}
            },
            beforeSend: function() {
                //status.empty();
                showMask();
                //var percentVal = '0%';
                var percentVal = '上传中....';
                bar.width(percentVal);
                percent.html(percentVal);
            },
            uploadProgress: function(event, position, total, percentComplete) {//上传的过程
                //position 已上传了多少
                //total 总大小
                //已上传的百分数
                var percentVal = percentComplete + '%';
                bar.width(percentVal);
                percent.html(percentVal);
                //console.log(percentVal+"=="+position+"=="+total);
            },
            success: function(data) {//成功
                var percentVal = '100%';
                bar.width(percentVal)
                percent.html(percentVal);                
            },
            error:function(err){//失败
                alert("表单提交异常！"+err.msg);
            },
            complete: function(xhr) {//完成
               // status.html(xhr.responseText);
                //save();
                hideMask(); 
            }
        });

    });
    
</script>
<body class="easyui-layout">
<div id="mask" class="mask" style="display: none;" >
		    <div class="progress" style="position:absolute;left:50%;transform:translateX(-50%);top:50%;transform:translateY(-50%)">
			    <div class="bar"></div >
			    <div class="percent">0%</div >
			</div> 
</div>
<form id="gclsForm">
<div data-options="region:'center',border:false,cls:'yujszhidongshibie'" style="overflow-y :hidden;padding: 7px;">
<div class="easyui-layout" data-options="fit:true">
	<div data-options="region:'north',border:false" style="height: 70px;overflow-y :hidden">
			<table cellspacing="0" cellpadding="0" border="0" width="100%" class="dananguanglikuang">	     
		     	 <tr>
		             <th align="right" height="26">号牌号码：</th>
		             <td>
		                 <input type="text" id="hphmmc" name="hphmmc"  value="${list.hphmmc }">
		             </td>
		             <th align="right" height="26">车辆品牌：</th>
		             <td>
		                 <input type="text" id="clpp1" name="clpp1"  value="${list.clpp1 }"/>
		             </td>
		             <th align="right" height="26">号牌种类：</th>
		             <td>
		                 <input type="text" id="hpzl" name="hpzl" value="${list.hpzlmc }"/>
		             </td>
		            <th align="right" height="26">车外廓长(mm)：</th>
		             <td>
		                 <input type="text" id="wkccmc" name="wkccmc"  value="${list.wkccmc }"/>
		             </td>
		         </tr>
		     	 <tr>
		             <th align="right">车辆颜色：</th>
		             <td>
		                 <input type="text" id="csys" name="csys"  value="${list.csysmc }"/>
		             </td>
		              <th align="right" height="26">车辆识别编号：</th>
		             <td>
		                 <input type="text" id="clsbdh" name="clsbdh" value="${list.clsbdh }"/>
		             </td>
		             <th align="right" height="26">发动机编号：</th>
		             <td>
		                <input type="text" id="fdjh" name="fdjh"  value="${list.fdjh }"/>
		             </td>
		             <th align="right" height="26">所有人：</th>
		             <td>
		                 <input type="text" id="syr" name="syr"  value="${list.syr }"/>
		             </td>
		         </tr>
		    </table>
		    </div>
		    <div data-options="region:'center',border:false">	
		    <div style="float:left;width:70%;height:93%" id="tpStyle">
		    </div>
		    <div style="float:right;" id="deviceOperation" >
		    <div id="parameters">	    		    
			    <a id="uploadwww" href="#" class="congzhim" onClick="javascript:base64EncodeFunc();" style="visibility: visible;">增加</a>
			    <a id="uploadwww" href="#" class="congzhim" onClick="javascript:Start1_onclick();" style="visibility: visible;">开启</a>
	  			<p>
				<input class="congzhim" type="button" value="选择扫描仪" onclick="selectScanner()" />
				<input class="congzhim" type="button" value="扫描" onclick="startScan()" />
				</p>
				<table border="1">			    
				<tr>
				  <td>像素类型:</td>
				  <td>
				   <!-- 设置图片保存路径 -->
				  	<input type="hidden" id="scanPath" size="10" value="D:\image\localImg"/>
				    <input type="radio" name="PixelType" value="0" />黑白<br />
				    <!-- <input type="radio" name="PixelType" value="1" />灰度<br /> -->
				    <input type="radio" name="PixelType" value="2" checked="checked" />彩色<br />
				  </td>
				</tr>
				<tr>
				  <td>分辨率:</td>
				  <td>
				    <input type="radio" name="Resolution" value="3" checked="checked"/>400 dpi<br />
				    <input type="radio" name="Resolution" value="4" />500 dpi<br />
				    <input type="radio" name="Resolution" value="5" />600 dpi<br />
				  </td>
				</tr>
				<tr>
				  <td>进纸模式:</td>
				  <td>
				    <input type="radio" name="PaperSupply" value="1" checked="checked"/>ADF正面<br />
				    <input type="radio" name="PaperSupply" value="2" />ADF双面<br />
				  </td>
				</tr>
				</table>
				</div>						
		    </div>				    		
		    </div>				    			    
</div>
</div>

	<div data-options="region:'east',border:false" style="width: 280px;overflow-y :hidden;padding: 7px 7px 7px 2px;">
	    	<div class="easyui-layout" data-options="fit:true" style="border:1px solid #d2d2d2;">
				<div data-options="region:'center',border:false" style="overflow-y :hidden">
					
							<p class="shipingjiemiangtanggr_top">
								采集记录
							</p>
							<ul class="shipingjiemiangtanggr_bottom" id="yxxxinfo">
							</ul>
				</div>
				<div data-options="region:'south',border:false" style="height: 60px;">
					<div class="diyipaidhusnfhenfnf1">
	         	       <a id="selectAllId" href="#" class="congzhim" onClick="javascript:selectAll();" style="visibility: visible;">全选</a>	             	            
	        	       <a id="delId" href="#" class="congzhim" onClick="javascript:delByselect();" style="visibility: visible;">删除</a>	             	            	              
		               <a id="saveId" href="#" class="congzhim" onClick="javascript:uploadPicAndSave();" style="visibility: visible;">保存采集</a>	             	            
		             </div> 
		             <div class="diyipaidhusnfhenfnf1">
		             		         	   <a id="preId" href="#" class="congzhim" style=" margin: 0 15px 0 0 ;" onClick="javascript:GoToPrePage();" style="visibility: visible;">上一条</a>
		               <a id="nextId" href="#" class="congzhim" onClick="javascript:GoToNextPage();" style="visibility: visible;">下一条</a>	               
		           </div> 
				</div>
			</div>

	    </div>
	    </form>
	    <div style="display: none;">
			<form id="uploadPicForm" name="uploadPicForm" action="${ctx}/imageitem/UploadImageFtp.htm" method="post" enctype="multipart/form-data">  <!-- target="submitFrame" -->
				    <input type="hidden" id="vehicleXh" name="xh" value="${list.xh }"/>
					<input type="hidden" id="hphmFlag"  name="hphm" value="${list.hphm }"/>
					<input type="hidden" id="hpzlFlag"  name="hpzl" value="${list.hpzl }"/>
					<input type="hidden" id="clpp1Flag" name="clpp1" value="${list.clpp1 }"/>
					<input type="hidden" id="clsbdhFlag" name="clsbdh" value="${list.clsbdh }"/>
					<input type="hidden" id="fdjhFlag"  name="fdjh" value="${list.fdjh }"/>
					<input type="hidden" id="csysFlag"  name="csys" value="${list.csys }"/>
					<input type="hidden" id="syrFlag"   name="syr" value="${list.syr }"/>
					<input type="hidden" id="fzjgFlag"  name="fzjg" value="${list.fzjg }"/>
					<input type="hidden" id="glbmFlag"  name="glbm" value="${list.glbm }"/>
					<input type="hidden" id="xzqhFlag"  name="xzqh" value="${list.xzqh }"/>
					<input type="hidden" id="gxsjFlag"  name="gxsj" value="${list.gxsj }"/>
					
				 <textarea id="imageBase64" name="imageBase64"></textarea>
				 <textarea id="fileTypeArea" name="fileTypeArea"></textarea>
			</form>
			<iframe style="width:0; height:0; margin-top:-10px;display: none;" name="submitFrame" src="about:blank"></iframe>
		</div>
		<!-- 扫描仪对象 -->
		<object id="fhkScan" width="0" height="0" classid="clsid:07cf3b59-2cf2-4ee2-bcef-1320638005e7"></object>
		<object id="img2base64" width="0" height="0" classid="clsid:4CAF60C8-668C-4E69-8C0A-9A8E0833F3FB"></object>	
	    <!-- 高拍仪对象 -->
		<object classid="clsid:454C18E2-8B7D-43C6-8C17-B1825B49D7DE" id="captrue"  width="0" height="0" ></object>
		<object classid="clsid:8622e61a-22d1-4c10-9ecc-4dfc1f9a4f03" id="cap" width="0" height="0"></object>
		
</body>
<script type="text/javascript">
/* var pageIndex=0;
var pageSize=1;
var pageTotal=0;
function GoToPrePage() {
    pageIndex -= 1;
    pageIndex = pageIndex >= 1 ? pageIndex : 1;
    AjaxGetData(pageIndex, pageSize);
}

function GoToNextPage() {
        pageIndex += 1;
        AjaxGetData(pageIndex, pageSize);
}
function AjaxGetData(index,size) {
	var startTime = $("#startTime").val();
	var endTime = $("#endTime").val();
	var hphm = encodeURI(encodeURI($("#hphmFlag").val()));
	var hpzl = $("#hpzlFlag").val();
	var yxzt = $("#yxztFlag").val();
	 $.ajax({
         url: "${ctx}/yxxx/findYxcjByxhUpAndDown.htm",
         type: "get",
         data: "page=" + pageIndex + "&pageSize=" + pageSize+"&hphm="+hphm+
        		"&hpzl="+hpzl+"&startTime="+startTime+"&endTime="+endTime+"&yxzt="+yxzt,
         dataType: "json",
         success:function(data){
	         //check(data.rows[0].tpurl);
	         judgePrePage(data.page);
	         judgeNextPage(index,pageTotal);
        	 $("#gclsForm").form('load',data.rows[0]); 
        	 showYxxxList(data.rows[0].xh);
         }
	 });
}
  $(function () {  
    pageIndex=parseInt('${page.page}');
    pageTotal=parseInt('${page.totalPages}');
    //check('${list.tpurl}');
    judgePrePage(pageIndex);
    judgeNextPage(pageIndex,pageTotal);
   // AjaxGetData(pageIndex, pageSize);
   //alert($("#vehicleXh").val());
   	showYxxxList($("#vehicleXh").val());

});  
  function judgePrePage(index){
	  if(index<=1){
		  $("#preId").removeClass("congzhim").addClass("congzhim1");
		  $("#preId").removeAttr("onclick");
	  }else{
		  $("#preId").removeClass("congzhim1").addClass("congzhim");
		  $("#preId").attr("onclick","GoToPrePage();");
	  }
  }
  function judgeNextPage(index,pageTotal){
	  if(index>=pageTotal){
		  $("#nextId").removeClass("congzhim").addClass("congzhim1");
		  $("#nextId").removeAttr("onclick");
	  }else{
		  $("#nextId").removeClass("congzhim1").addClass("congzhim");
		  $("#nextId").attr("onclick","GoToNextPage();");
	  }
  } */
  //显示图片列表
  function showYxxxList(vehicleXh) {
		$.ajax({
			type:'POST',
			url:'${ctx}/yxxx/findYxcjRelation.htm',
			data:{xh:vehicleXh},
			dataType:'json',
			success:function(data, textStatus, jqXHR){
				//changeSrc(data[0].tpurl);
				$("#yxxxinfo").html("");
				var tableBodyStr = "";
				  if(data==""){
				      tableBodyStr+="<p class=\"xiangguanxinxzhifjiluyi1\" style=\"border:none;width:200px\">没有符合条件的查询结果！</p>";
				    }else{						    	
				      $.each(data,function(i,n){				    	  
						if (n.tpurl != "") {
							var str = n.tpurl;
							//var str = n.pic.replace(".jpg",".thm.jpg");
							var tpid= n.tpid+i;
							tableBodyStr += "<li>";
							tableBodyStr += "<input type=\"hidden\" name=\"fileTypeFlag\" value=\"2323\">";
							tableBodyStr += "<input type=\"checkbox\" name=\"checkbox1\" id=\""+tpid+"\" value=\""+tpid+"\">";
							tableBodyStr += "<img id=\""+tpid+"\" onerror=\"javascript:this.src='${ctx}/images/tupiangsd.png'\" src=\""+str+"\" width=\"70%\" height=\"70%\" style=\"float: left; margin: 0 5px 0 0;\" onclick=\"javascript:changeSrc(this.src)\"/>";
							tableBodyStr += "<select onchange=\"OnChangFunc(this)\"> "+
											"  <option value =\"\" selected >请选择档案类型</option> "+
											"  <option value =\"1\">身份证明</option> "+
											"  <option value =\"2\">申请表</option> "+
											"  <option value =\"3\">交强险</option> "+
											"  <option value =\"4\">纳税证明</option> "+
											"</select>";
							tableBodyStr += "</li>";
							
						}else{
							tableBodyStr += "<li>";
							tableBodyStr += "<img onerror=\"javascript:this.src='${ctx}/images/tupiangsd.png'\" width=\"100%\" height=\"100%\" style=\"float: left; margin: 0 10px 0 0;\" onclick=\"javascript:changeSrc()\"/>";
							tableBodyStr += "</li>";
						}
				      });
				    }
				  $.parser.parse($('#selectCom2'));
				 $("#yxxxinfo").html(tableBodyStr);
				//$("#yxxxinfo").html(addPicTest(tableBodyStr));
			},
			error:function(XMLHttpRequest, textStatus, errorThrown){
				
			}
		});
	}
  function OnChangFunc(obj){
	  var selectedOption=obj.options[obj.selectedIndex];
	  //console.info($(obj).prev()[0].getAttribute("name"));
	  $(obj).parent().children("input[name='fileTypeFlag']").val(selectedOption.value);
  }
  function Start1_onclick()
  {
        var str=captrue.bStopPlay(); 
        var str=captrue.vSetResolution(7); 	
        var str=captrue.bStartPlayRotate(270);
		var str = captrue.bSetMode(1);
	var str = captrue.bSetImageArea(0,0,9900,9300);
  }
  function base64EncodeFunc(){
	  alert(captrue.Base64Encode("D:\\image\\1496907499327.jpg"));
  }
  //显示大图
  function changeSrc(srcValue){
		var playPic = "";
		$("#tpStyle").html("");
		playPic +="<img id=\"imggc\"  onerror=\"javascript:this.src='${ctx}/images/wutuffs.png'\" src=\""+srcValue+"\">";
		$("#tpStyle").html(playPic);
	}
  //删除选中项
  function delByselect(){
	  /* $("input[name='checkbox1']:checked").each(function(i,n){
	        var logoid=$(this).val();
	        if(i==0){
	            logoids+=logoid;
	        }else{
	            logoids+=","+logoid;
	        }
	    });*/
	  var  checkboxArray =[];
		var ckbs = document.getElementById("yxxxinfo").getElementsByTagName("input");
		var len = ckbs.length;
		for(var i=0;i<len;i++){
		    if(ckbs[i].type == "checkbox" && ckbs[i].checked==true){
		    	checkboxArray.push(ckbs[i].value); 
		  }
		}
		for(var j=0;j<checkboxArray.length;j++){
			 $("#"+checkboxArray[j]).parent().remove();
			 //map.remove(checkboxArray[j]);
		  } 
  }
/*   $('#yxxxinfo li').live('click',function(){
		//$('input').removeAttr('checked');	
	 	if($(this).find("input[type='checkbox']").prop("checked")){
			$(this).find("input[type='checkbox']").prop('checked',false); 
		}else{
			$(this).find("input[type='checkbox']").prop('checked',true);
		}  
	}) */
	//全部选中
	function selectAll(){
	        if($("input[name='checkbox1']").prop("checked")){
	        	$("input[name='checkbox1']").prop("checked", false);         	
			}else{
				$("input[name='checkbox1']").prop("checked", true); 
			}  
  		}

    
  	//保存采集信息
  	function save(){
  		try{
      		var listImgObj=document.getElementById("yxxxinfo").getElementsByTagName("img");
      	}catch(e){
      			alert("无档案信息,请上传档案文件后再保存！");
      			return;
      		}
  		var v_vehicleXh =$("#vehicleXh").val();
  		var ImgStr=new Array();
  		 for(var i=0;i<listImgObj.length;i++){
  			 if(listImgObj[i].src!=null){ 				 
  				 ImgStr.push(listImgObj[i].src);
  				 } 			 
  		}

  		$.ajax({
			type:'POST',
			url:'${ctx}/yxxx/updateYxcjRelation.htm',
			data:{xh:v_vehicleXh,
				  tpurlarray:ImgStr},
			dataType:'json',
			success:function(data, textStatus, jqXHR){
				alert("保存成功！");
				GoToNextPage();
			}
  		});
  	}
		
    //上传图片并保存
    function uploadPicAndSave(){
   	var imgArray = document.getElementById("yxxxinfo").getElementsByTagName("img");
	if(imgArray.length<1){
		alert("无档案信息,请上传档案文件后再保存！");
		return;
	}
	for(var i=0;i<imgArray.length;i++){
		if($(imgArray[i]).parent().children("input[name='fileTypeFlag']").val()==null || $(imgArray[i]).parent().children("input[name='fileTypeFlag']").val()==''){
			alert("有档案类型未标注！");
			return;
		}				
	}
    var imageBase64Results = document.getElementById("imageBase64");
    var fileTypeAreaResults = document.getElementById("fileTypeArea");   
    var imageBase64Str =imageBase64Results.value;
    var fileTypeAreaStr =fileTypeAreaResults.value;
    for(var i=0;i<imgArray.length;i++){
    	if(imageBase64Str!=''){
    	if(imgArray[i].src.indexOf("http")!=-1){
    		imageBase64Str +=',';
    		imageBase64Str +=imgArray[i].src;
    		fileTypeAreaStr +=',';
    		fileTypeAreaStr +=$(imgArray[i]).parent().children("input[name='fileTypeFlag']").val();
    	}else{
    		imageBase64Str +=',';
    		imageBase64Str += captrue.Base64Encode(imgArray[i].src.substring(imgArray[i].src.indexOf("///")+3));
    		fileTypeAreaStr +=',';
    		fileTypeAreaStr += $(imgArray[i]).parent().children("input[name='fileTypeFlag']").val();
    	}
      }else{
    	  if(imgArray[i].src.indexOf("http")!=-1){
      		imageBase64Str +=imgArray[i].src;
    		fileTypeAreaStr +=$(imgArray[i]).parent().children("input[name='fileTypeFlag']").val();
      	}else{
      		imageBase64Str += captrue.Base64Encode(imgArray[i].src.substring(imgArray[i].src.indexOf("///")+3));
    		fileTypeAreaStr += $(imgArray[i]).parent().children("input[name='fileTypeFlag']").val();
    		//alert(imgArray[i].src+"=="+captrue.Base64Encode(imgArray[i].src.substring(imgArray[i].src.indexOf("///")+3)));
      	}
      }
    }
   /*  for(var i=0;i<map.size();i++){
    	if(imageBase64Str!=''){
    	    imageBase64Str +=','
    	    imageBase64Str += map.get(ckbs[i].value);
    	}else{
    		imageBase64Str += map.get(ckbs[i].value);
    	}
    }*/
    imageBase64Results.value=imageBase64Str;
    fileTypeAreaResults.value=fileTypeAreaStr;
    $("#uploadPicForm").submit();
    $("#imageBase64").val(''); 
    $("#fileTypeArea").val(''); 
    $("#uploadPicForm")[0].reset();
    }
    
    function addPic(Str,randDom){
    	
    	var tableBodyStr="";
	  	tableBodyStr += "<li>";
	  	tableBodyStr += "<input type=\"hidden\" name=\"fileTypeFlag\">";
		tableBodyStr += "<input type=\"checkbox\" name=\"checkbox1\" id=\""+randDom+"\" value=\""+randDom+"\">";
		tableBodyStr += "<img id=\""+randDom+"\" value=\""+randDom+"\" src=\""+Str+"\" width=\"70%\" height=\"70%\" style=\"float: left; margin: 0 5px 0 0;\" onclick=\"javascript:changeSrc(this.src)\">";
		tableBodyStr += "<select onchange=\"OnChangFunc(this)\"> "+
						"  <option value =\"\" selected >请选择档案类型</option> "+
						"  <option value =\"1\">身份证明</option> "+
						"  <option value =\"2\">申请表</option> "+
						"  <option value=\"3\">交强险</option> "+
						"  <option value=\"4\">纳税证明</option> "+
						"</select>";	
		tableBodyStr += "</li>";
		
		document.getElementById('yxxxinfo').innerHTML+=tableBodyStr;		
    }
    //生成固定长度随机数
    function GetRandomNum(n){
	    var chars = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
         var res = "";
         for(var i = 0; i < n ; i ++) {
             var id = Math.ceil(Math.random()*35);
             res += chars[id];
         }
         return res;
    }
</script>
<!-- 扫描仪脚本 开始-->
<script>
//选择扫描仪
function selectScanner()
{
	var rtn = fhkScan.SelectSource(0);
	if (rtn == -1)
	{
		alert("Select scanner error, error code = " + fhkScan.ErrorCode);
	}
}
//初始化扫描仪
function InitSettings()
{
	//本地路径设置
	fhkScan.FileName = document.getElementById("scanPath").value;
	
	//设置像素类型：pixelType
	var pixelType = 0;
	var rdbPixelType = document.getElementsByName("PixelType");
	for (var i = 0; i < rdbPixelType.length; i++)
	{
		if (rdbPixelType[i].checked)
		{
			pixelType = rdbPixelType[i].value;
			break;
		}
	}
	if (pixelType == 0)
	{
		// Scan to Black & White
		fhkScan.PixelType = 0;				// 0 - Black & White, 1 - Grayscale, 2 - RGB Color
		fhkScan.FileType = 1;				// 0 - BMP, 1 - TIFF, 2 - Multipage TIFF, 3 - JPEG
		fhkScan.CompressionType = 4;		// 0 - No compress, 4 - CCITT G4 (only for B&W), 5 - JPEG
	}
	else
	{
		// Scan to Gray or Color
		fhkScan.PixelType = pixelType;		// 0 - Black & White, 1 - Grayscale, 2 - RGB Color
		fhkScan.FileType = 3;				// 0 - BMP, 1 - TIFF, 2 - Multipage TIFF, 3 - JPEG
		fhkScan.JPGQuality = 4;				// JPEG data compression level, 0 (small file size) ~ 6 (large file size)
		//fhkScan.CompressionType = 5;
	}

	//设置分辨率:resolution
	var resolution = 0;
	var rdbResolution = document.getElementsByName("Resolution");
	for (var i = 0; i < rdbResolution.length; i++)
	{
		if (rdbResolution[i].checked)
		{
			resolution = rdbResolution[i].value;
			break;
		}
	}
	fhkScan.Resolution = resolution;		// 0 - 200 dpi, 1 - 240 dpi, 2 - 300 dpi, 3 - 400 dpi, 4 - 500 dpi, 5 - 600 dpi

	//设置进纸模式:paperSupply
	var paperSupply = 2;
	var rdbPaperSupply = document.getElementsByName("PaperSupply");
	for (var i = 0; i < rdbPaperSupply.length; i++)
	{
		if (rdbPaperSupply[i].checked)
		{
			paperSupply = rdbPaperSupply[i].value;
			break;
		}
	}
	// 0 - Flatbed, 1 - ADF front, 2 - ADF double 3 - Auto
	if(paperSupply==3)
	{
		fhkScan.PaperSupply =2;				
		fhkScan.AutomaticSenseMedium=true;
	}
	else 
	{
		fhkScan.PaperSupply = paperSupply;
		fhkScan.AutomaticSenseMedium=false;
	}
	//设置旋转角度:scanRotate
	/* var scanRotate = 0;
	var rdbScanRotate = document.getElementsByName("ScanRotate");
	for (var i = 0; i < rdbScanRotate.length; i++)
	{
		if (rdbScanRotate[i].checked)
		{
			scanRotate = rdbScanRotate[i].value;
			break;
		}
	} */
	fhkScan.ScanRotate = 4;		// 0 - None, 1 - 90 degrees, 2 - 180 degrees, 3 - 270 degrees, 4 - Automatic
	//跳过空白页：SkipWhitePage
	/* var chkSkipWhitePage = document.getElementById("SkipWhitePage");
	if (chkSkipWhitePage.checked)
	{
		fhkScan.SkipWhitePage = 6; 			// 0 - Do not skip, 1~15 - the ratio of black dots in the white page
	}
	else
	{
		fhkScan.SkipWhitePage = 0; 			// 0 - Do not skip, 1~15 - the ratio of black dots in the white page
	} */
	fhkScan.SkipWhitePage = 6; 
	
	//显示源用户界面:chkShowSourceUI
	/* var chkShowSourceUI = document.getElementById("ShowSourceUI");
	if (chkShowSourceUI.checked)
	{
		fhkScan.ShowSourceUI = true;		// true - Display the scanner source UI, false - Do not display
	}
	else
	{
		fhkScan.ShowSourceUI = false;		// true - Display the scanner source UI, false - Do not display
	} */
	fhkScan.ShowSourceUI = false; 
	//文件重写提示:chkPromptOverwrite
	/* var chkPromptOverwrite = document.getElementById("PromptOverwrite");
	if (chkPromptOverwrite.checked)
	{
		fhkScan.Overwrite = 2;
	}
	else
	{
		fhkScan.Overwrite = 1;
	} */
	fhkScan.Overwrite = 1;  //2 :提示，1：自动覆盖
	
	fhkScan.ScanTo = 0;					// 0 - to File, 1 - to DIB, 2 - to Memory, Suggest to File
	fhkScan.ScanCount = -1;				// Number of pages to scan, -1 - all pages on ADF
	fhkScan.DetectPageSize = 2;
	fhkScan.SourceCurrentScan = 0;
}
//扫描入口
function startScan() 
{
	InitSettings(); //参数初始化
	var rtn = fhkScan.OpenScanner(0); //打开扫描仪
	if (rtn == -1)
	{
	    alert("Open scanner error, error code = " + fhkScan.ErrorCode);
		return;
	} 	
	rtn = fhkScan.StartScan(0); //开始扫描
	if (rtn == -1)
	{
		alert("Start scan error, error code = " + fhkScan.ErrorCode);
	}
	fhkScan.CloseScanner(0); //关闭扫描
}

//var map = new Map();

//扫描绑定事件，美扫描一次，调用一次此事件
function OnScanToFileEvent(scanFilePath)
{
	// Transform scanned jpg file to Base64 string
	// parameters:
	//   1. full path of the file to be transformed
	//   2. true - delete source jpg file, false - keep the jpg file
	//var base64 = img2base64.DoTrans(scanFilePath, false);  //图片转换成Base64

	/* var imageBase64Results = document.getElementById("imageBase64");
	var imageBase64Str = imageBase64Results.value;
	if(imageBase64Str!=''){
	    imageBase64Str +=','
	    imageBase64Str += base64;
	}else{
		imageBase64Str += base64;
	}
	addPic(scanFilePath);
	imageBase64Results.value=imageBase64Str; */
	
	var randDom=GetRandomNum(15);
	//var fileName=scanFilePath.substring(scanFilePath.lastIndexOf("\\")+1,scanFilePath.lastIndexOf("."));
	//map.put(randDom,base64);
	addPic(scanFilePath,randDom);
} 

</script> 

<script for="fhkScan" event="ScanToFile(scanFilePath)">
	OnScanToFileEvent(scanFilePath);
</script>

<!-- 扫描仪脚本 结束-->
</html>